Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jan 1, 2026

This PR introduces an or-pattern syntax, allowing the same patch to be applied to multiple generated types.

Example

import_types!(
  schema = "../schema.json",
  patches = {
    Foo | Bar = {
      derives = [/* ... */],
    },
  },
);

Copy link
Collaborator

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work if rename is specified?

@ghost
Copy link
Author

ghost commented Jan 8, 2026

How would this work if rename is specified?

Good question. This would require a simple restriction preventing patches that use the or-pattern from specifying renames when applied to multiple types. I used PatchType as the foundation for implementing variant patches (via a PatchType::Path variant), so rename is still supported for variants, but not when applied to types.

Similarly, variant patches should not be able to specify derives, so I added a restriction for that as well. Let me know if you would like me to implement something similar.

@ahl
Copy link
Collaborator

ahl commented Jan 11, 2026

So the use case here is that you have a bit chunk of the generated types for which you want an additional derive macro applied? Many, but not all?

@ghost
Copy link
Author

ghost commented Jan 11, 2026

So the use case here is that you have a bit chunk of the generated types for which you want an additional derive macro applied? Many, but not all?

Yes, some macros (e.g. wasm_bindgen) do not support certain data types, so they would need to be applied via a patch, and it would be useful if this patch were not duplicated.

That is my use case.

@ghost ghost closed this by deleting the head repository Jan 27, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant